﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FS.Model.Model;
using NHibernate;
using NHibernate.Cfg;

namespace Fruit.DAL
{
    /// <summary>
    /// 用户信息-数据访问
    /// </summary>
    public class UserInfoService
    {
        private ISession _Session;

        public UserInfoService()
        {
            _Session = new SessionService().GetSession();
        }

        public UserInfoService(ISession session)
        {
            _Session = session;
        }

        public ISession Session
        {
            get { return _Session; }
            set { _Session = value; }
        }

        /// <summary>
        ///  保存或者修改用户信息
        /// </summary>
        /// <returns></returns>
        public void SaveOrUpdate(UserInfo userinfo)
        {
            ITransaction tx = null;
            tx = _Session.BeginTransaction();
            _Session.SaveOrUpdate(userinfo);
            tx.Commit();
        }
    }
}
